Originally Posted by
laserlight
No, there is no such rule. However, there are two rules (from C99 Clause 7.1.3 Paragraph 1) that say:
- All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
- All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
A simple rule of thumb is just to avoid naming things with names that begin with an underscore.
The thing is, "something like" is not convincing. For example, compile this program:
Code:
#include <stdio.h>
typedef struct X {
double a;
int b;
} abc_def;
int main(void)
{
abc_def x = {1.2, 3};
printf("%f %d\n", x.a, x.b);
return 0;
}
What error do you get?
Tried. And gives no error.
I've also tried to write it my way (noobie way) and it still gives no error. I surrender, I dont know why I got the error before but not now. =p
What I know is that the name had a "_" in the middle and stopped giving the error after I took the "_" off.
Code:
#include <stdio.h>
typedef struct X { //YOUR WAY
double a;
int b;
} abc_def;
int main(void)
{
abc_def x = {1.2, 3};
printf("%f %d\n", x.a, x.b);
struct y_j //MY WAY
{
int a;
int b;
};
typedef struct y_j z_w;
z_w * a;
return 0;
}